Repository navigation
feat: サインインした後に購入をいまのユーザーへ移す syncPurchases を足す - #9
Merged
Merged
Conversation
syncUser は身元を入れ替えるだけなので、前の身元で始めたトライアルは 「購入を復元」を押すまで新しいアカウントに付かなかった。 syncPurchases は Purchases.syncPurchases を包み、何も出さずに購入を移して SubscriptionStatus を返す。起動時の syncUser には組み込まない (既定の transfer behavior で使い捨てのアカウントが購入を奪うため)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
何のため
2026-11-01、ごほうび習慣でトライアルを始めた人が2台目の端末でサインインしたところ、
syncUser(userId:)がlogInしかしないため Premium が前の身元に残り、「購入を復元」を押すまで付かなかった。変えたこと
SubscriptionUseCase.syncPurchases()を足した。Purchases.shared.syncPurchases()を包み、UIを出さずに購入をいまの身元へ移し、キャッシュを更新してSubscriptionStatusを返す。失敗はSubscriptionError.userSyncFailedcheckSubscriptionStatus()で答える(既存の準拠はそのままコンパイルが通る)。PreviewSubscriptionUseCaseも実装syncUserには組み込まない。 RevenueCat の transfer behavior は既定で「新しい App User ID へ移す」なので、起動ごとに同期すると入れ直しで作られた使い捨てのアカウントが購入を奪う。呼ぶのは本人が明示的にサインインして uid が変わった時だけ(ドキュメントに明記)確かめたこと
swift build/swift testが通るSyncPurchasesTests:結果のキャッシュ反映・サインイン後に前の身元の購入が付く・syncUserは同期を呼ばない・失敗してもキャッシュは変わらない・既定実装scripts/release.sh --dry-run:bump=minor(3.5.0 → 3.6.0、削除0・追加4)🤖 Generated with Claude Code